/*   1:    */ package com.rinsi.app.azsb.azzl.zqyjs;
/*   2:    */ 
/*   3:    */ import com.rinsi.core.contoller.CoreSimpleController;
/*   4:    */ import com.rinsi.core.service.CoreSimpleService;
/*   5:    */ import com.rinsi.util.CodeUtil;
/*   6:    */ import com.rinsi.util.FileUtil;
/*   7:    */ import com.rinsi.util.SpringContextUtil;
/*   8:    */ import java.io.BufferedInputStream;
/*   9:    */ import java.io.File;
/*  10:    */ import java.io.FileInputStream;
/*  11:    */ import java.io.PrintWriter;
/*  12:    */ import java.util.List;
/*  13:    */ import java.util.Map;
/*  14:    */ import javax.servlet.ServletOutputStream;
/*  15:    */ import javax.servlet.http.HttpServletRequest;
/*  16:    */ import javax.servlet.http.HttpServletResponse;
/*  17:    */ import org.springframework.beans.factory.annotation.Autowired;
/*  18:    */ import org.springframework.stereotype.Controller;
/*  19:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  20:    */ import org.springframework.web.bind.annotation.RequestParam;
/*  21:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  22:    */ import org.springframework.web.multipart.MultipartFile;
/*  23:    */ 
/*  24:    */ @Controller
/*  25:    */ @RequestMapping({"/azsb/azzl/zqyjs"})
/*  26:    */ public class ZqyjsController
/*  27:    */   extends CoreSimpleController
/*  28:    */ {
/*  29:    */   @Autowired
/*  30:    */   private ZqyjsService zqyjsService;
/*  31:    */   
/*  32:    */   @ResponseBody
/*  33:    */   @RequestMapping({"/download"})
/*  34:    */   public void download(@RequestParam String filename, HttpServletRequest request, HttpServletResponse response)
/*  35:    */   {
/*  36: 43 */     BufferedInputStream bis = null;
/*  37:    */     try
/*  38:    */     {
/*  39: 47 */       File file = new File(new String(filename.getBytes("ISO-8859-1"), "utf-8"));
/*  40:    */       
/*  41: 49 */       String mod = request.getParameter("MODULE_NO") + "/";
/*  42:    */       
/*  43: 51 */       String filepath = (String)((Map)SpringContextUtil.getBean("config")).get("filepath") + mod + "/";
/*  44:    */       
/*  45: 53 */       String ID = request.getParameter("ID") + "/";
/*  46:    */       
/*  47: 55 */       filepath = filepath + ID;
/*  48:    */       
/*  49: 57 */       filepath = filepath + CodeUtil.code(FileUtil.getBaseFileName(file)) + "." + FileUtil.getFileType(file);
/*  50:    */       
/*  51: 59 */       File finalFile = new File(filepath);
/*  52:    */       
/*  53: 61 */       bis = new BufferedInputStream(new FileInputStream(finalFile));
/*  54:    */       
/*  55: 63 */       byte[] buff = new byte[2048];
/*  56:    */       int bytesRead;
/*  57: 67 */       while (-1 != (bytesRead = bis.read(buff, 0, buff.length)))
/*  58:    */       {
/*  59:    */         //int bytesRead;
/*  60: 69 */         response.getOutputStream().write(buff);
/*  61:    */       }
/*  62:    */     }
/*  63:    */     catch (Exception e)
/*  64:    */     {
/*  65: 74 */       e.printStackTrace();
/*  66:    */       try
/*  67:    */       {
/*  68: 79 */         if (bis != null) {
/*  69: 80 */           bis.close();
/*  70:    */         }
/*  71:    */       }
/*  72:    */       catch (Exception e1)
/*  73:    */       {
/*  74: 84 */         e1.printStackTrace();
/*  75:    */       }
/*  76:    */     }
/*  77:    */     finally
/*  78:    */     {
/*  79:    */       try
/*  80:    */       {
/*  81: 79 */         if (bis != null) {
/*  82: 80 */           bis.close();
/*  83:    */         }
/*  84:    */       }
/*  85:    */       catch (Exception e)
/*  86:    */       {
/*  87: 84 */         e.printStackTrace();
/*  88:    */       }
/*  89:    */     }
/*  90:    */   }
/*  91:    */   
/*  92:    */   @ResponseBody
/*  93:    */   @RequestMapping({"/upload"})
/*  94:    */   public void upload(@RequestParam MultipartFile file, HttpServletRequest request, HttpServletResponse response)
/*  95:    */   {
/*  96:    */     try
/*  97:    */     {
/*  98: 97 */       String mod = request.getParameter("MODULE_NO") + "/";
/*  99:    */       
/* 100: 99 */       String filepath = (String)((Map)SpringContextUtil.getBean("config")).get("filepath") + mod + "/";
/* 101:    */       
/* 102:101 */       String ID = request.getParameter("ID") + "/";
/* 103:    */       
/* 104:103 */       filepath = filepath + ID;
/* 105:    */       
/* 106:105 */       List<Map<String, Object>> files = FileUtil.getFileList(filepath);
/* 107:107 */       if (files.size() > 0) {
/* 108:109 */         FileUtil.deleteExistedFile(filepath, ((Map)files.get(0)).get("filename") + "." + ((Map)files.get(0)).get("filetype"));
/* 109:    */       }
/* 110:113 */       FileUtil.createFile(filepath, file.getOriginalFilename(), file.getBytes());
/* 111:    */       
/* 112:115 */       response.setCharacterEncoding("UTF-8");
/* 113:    */       
/* 114:117 */       response.getWriter().print(file.getOriginalFilename());
/* 115:    */     }
/* 116:    */     catch (Exception e)
/* 117:    */     {
/* 118:121 */       e.printStackTrace();
/* 119:    */     }
/* 120:    */   }
/* 121:    */   
/* 122:    */   public CoreSimpleService servce()
/* 123:    */   {
/* 124:130 */     return this.zqyjsService;
/* 125:    */   }
/* 126:    */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.app.azsb.azzl.zqyjs.ZqyjsController
 * JD-Core Version:    0.7.0.1
 */